package com.coolweather.leo_anim;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

public class MainActivity2 extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dong);

        ImageView imageView = findViewById(R.id.iv);
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //通过加载xml动画设置文件来创建一个Animation对象
                //由透明到不透明变化
                Animation animation = AnimationUtils.loadAnimation(MainActivity2.this,R.anim.alpa);

                //实现从中心开始旋转
                //Animation animation = AnimationUtils.loadAnimation(MainActivity2.this,R.anim.rotate);

                //实现缩放
                //Animation animation = AnimationUtils.loadAnimation(MainActivity2.this,R.anim.scale);

                //实现平移
                //Animation animation = AnimationUtils.loadAnimation(MainActivity2.this,R.anim.translate);
                imageView.startAnimation(animation);
            }
        });
    }
}